package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.Zichan;
import com.dkd.manage.service.IZichanService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 资产设备管理Controller
 *
 * @author zqy
 * @date 2024-12-25
 */
@Api(tags = "资产设备管理Controller")
@RestController
@RequestMapping("/manage/zichan")
public class ZichanController extends BaseController
{
    @Autowired
    private IZichanService zichanService;

/**
 * 查询资产设备管理列表
 */
@ApiOperation("查询资产设备管理列表")
@PreAuthorize("@ss.hasPermi('manage:zichan:list')")
@GetMapping("/list")
    public TableDataInfo list(Zichan zichan)
    {
        startPage();
        List<Zichan> list = zichanService.selectZichanList(zichan);
        return getDataTable(list);
    }

    /**
     * 导出资产设备管理列表
     */
    @ApiOperation("导出资产设备管理列表")
    @PreAuthorize("@ss.hasPermi('manage:zichan:export')")
    @Log(title = "资产设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Zichan zichan)
    {
        List<Zichan> list = zichanService.selectZichanList(zichan);
        ExcelUtil<Zichan> util = new ExcelUtil<Zichan>(Zichan.class);
        util.exportExcel(response, list, "资产设备管理数据");
    }

    /**
     * 获取资产设备管理详细信息
     */
    @ApiOperation("获取资产设备管理详细信息")
    @PreAuthorize("@ss.hasPermi('manage:zichan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zichanService.selectZichanById(id));
    }

    /**
     * 新增资产设备管理
     */
    @ApiOperation("新增资产设备管理")
    @PreAuthorize("@ss.hasPermi('manage:zichan:add')")
    @Log(title = "资产设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Zichan zichan)
    {
        return toAjax(zichanService.insertZichan(zichan));
    }

    /**
     * 修改资产设备管理
     */
    @ApiOperation("修改资产设备管理")
    @PreAuthorize("@ss.hasPermi('manage:zichan:edit')")
    @Log(title = "资产设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Zichan zichan)
    {
        return toAjax(zichanService.updateZichan(zichan));
    }

    /**
     * 删除资产设备管理
     */
    @ApiOperation("删除改资产设备管理")
    @PreAuthorize("@ss.hasPermi('manage:zichan:remove')")
    @Log(title = "资产设备管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zichanService.deleteZichanByIds(ids));
    }
}
